home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / TerminalPanel.c < prev    next >
C/C++ Source or Header  |  1995-06-17  |  17KB  |  690 lines

  1. /*
  2. **    TerminalPanel.c
  3. **
  4. **    Editing panel for terminal configuration
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_EMULATIONTYPE=1, GAD_EMULATIONLIBRARY, GAD_COLUMNS, GAD_LINES,
  13.         GAD_KEYMAP, GAD_TEXTFONT, GAD_FONTMODE, GAD_EMULATIONTASK, GAD_IBMFONT,
  14.         GAD_USE, GAD_CANCEL, GAD_DEFAULT, GAD_PAGER, GAD_PAGEGROUP
  15.     };
  16.  
  17. STATIC LONG    LocalMaxColumns,
  18.         LocalMaxLines;
  19.  
  20. STATIC STRPTR __saveds
  21. ShowColumn(struct Gadget *SomeGadget,WORD Level)
  22. {
  23.     STATIC UBYTE Buffer[10];
  24.  
  25.     if(Level == LocalMaxColumns + 1)
  26.         strcpy(Buffer,LocaleString(MSG_TERMINALPANEL_MAXIMUM_TXT));
  27.     else
  28.         SPrintf(Buffer,LocaleBase ? "%9lD" : "%9ld",Level);
  29.  
  30.     return(Buffer);
  31. }
  32.  
  33. STATIC STRPTR __saveds
  34. ShowLine(struct Gadget *SomeGadget,WORD Level)
  35. {
  36.     STATIC UBYTE Buffer[10];
  37.  
  38.     if(Level == LocalMaxLines + 1)
  39.         strcpy(Buffer,LocaleString(MSG_TERMINALPANEL_MAXIMUM_TXT));
  40.     else
  41.         SPrintf(Buffer,LocaleBase ? "%9lD" : "%9ld",Level);
  42.  
  43.     return(Buffer);
  44. }
  45.  
  46.     /* SelectKeymap(UBYTE *Name,struct Window *ParentWindow):
  47.      *
  48.      *    Select a new keymap file using the asl.library file requester.
  49.      */
  50.  
  51. STATIC BYTE __regargs
  52. SelectKeymap(UBYTE *Name,struct Window *ParentWindow)
  53. {
  54.     struct FileRequester    *AslFileRequest;
  55.     struct TagItem         DimensionTags[5];
  56.     UBYTE            *File,*Temp;
  57.     BYTE             NewMap = FALSE;
  58.  
  59.     File = Name;
  60.  
  61.     strcpy(SharedBuffer,File);
  62.  
  63.     Temp = PathPart(SharedBuffer);
  64.  
  65.     Temp[0] = 0;
  66.  
  67.     if(!SharedBuffer[0])
  68.     {
  69.         APTR OldPtr = ThisProcess -> pr_WindowPtr;
  70.         BPTR FileLock;
  71.  
  72.         ThisProcess -> pr_WindowPtr = (APTR)-1;
  73.  
  74.         if(FileLock = Lock("KEYMAPS:",ACCESS_READ))
  75.         {
  76.             strcpy(SharedBuffer,"KEYMAPS:");
  77.  
  78.             UnLock(FileLock);
  79.         }
  80.         else
  81.             strcpy(SharedBuffer,"Devs:Keymaps");
  82.  
  83.         ThisProcess -> pr_WindowPtr = OldPtr;
  84.     }
  85.  
  86.     File = FilePart(File);
  87.  
  88.     if(AslFileRequest = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
  89.         ASL_Window,    ParentWindow,
  90.         ASL_File,    File,
  91.         ASL_Dir,    SharedBuffer,
  92.         ASL_Hail,    LocaleString(MSG_TERMINALPANEL_SELECT_KEYMAP_TXT),
  93.         ASL_FuncFlags,    FILF_NEWIDCMP,
  94.         ASL_OKText,    LocaleString(MSG_GLOBAL_SELECT_TXT),
  95.     TAG_MORE,GetDimensionTags(ParentWindow,DimensionTags)))
  96.     {
  97.         if(AslRequestTags(AslFileRequest,TAG_DONE))
  98.         {
  99.             STRPTR FileName;
  100.  
  101.             if(AslFileRequest -> rf_NumArgs > 1 && AslFileRequest -> rf_ArgList)
  102.                 FileName = AslFileRequest -> rf_ArgList -> wa_Name;
  103.             else
  104.                 FileName = AslFileRequest -> rf_File;
  105.  
  106.             if(FileName[0])
  107.             {
  108.                 PutDimensionTags(ParentWindow,AslFileRequest -> rf_LeftEdge,AslFileRequest -> rf_TopEdge,AslFileRequest -> rf_Width,AslFileRequest -> rf_Height);
  109.  
  110.                 strcpy(SharedBuffer,AslFileRequest -> rf_Dir);
  111.  
  112.                 if(!AddPart(SharedBuffer,FileName,MAX_FILENAME_LENGTH))
  113.                     strcpy(SharedBuffer,FileName);
  114.  
  115.                 if(Stricmp(SharedBuffer,Name))
  116.                 {
  117.                     strcpy(Name,SharedBuffer);
  118.  
  119.                     NewMap = TRUE;
  120.                 }
  121.             }
  122.         }
  123.  
  124.         FreeAslRequest(AslFileRequest);
  125.     }
  126.  
  127.     return(NewMap);
  128. }
  129.  
  130. BYTE __regargs
  131. TerminalPanel(struct Configuration *LocalConfig,BYTE *Default)
  132. {
  133.     STATIC LONG PageTitleID[5] =
  134.     {
  135.         MSG_V36_1020,
  136.         MSG_V36_1021,
  137.         MSG_V36_1024,
  138.         MSG_V36_1025,
  139.         -1
  140.     };
  141.  
  142.     STATIC BYTE         InitialPage = 0;
  143.  
  144.     struct LayoutHandle    *Handle;
  145.     BYTE             Cancel = FALSE;
  146.     STRPTR             PageTitle[5];
  147.  
  148.     LocalizeStringTable(PageTitle,PageTitleID);
  149.  
  150.     SaveConfig(LocalConfig,PrivateConfig);
  151.  
  152.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  153.         LH_LocaleHook,    &LocaleHook,
  154.         LH_ExitFlush,    FALSE,
  155.     TAG_DONE))
  156.     {
  157.         struct Window    *PanelWindow;
  158.         LONG         LocalColumns,
  159.                  LocalLines;
  160.         UBYTE         FontName[MAX_FILENAME_LENGTH],
  161.                  IBMName[MAX_FILENAME_LENGTH];
  162.  
  163.         BuildFontName(FontName,LocalConfig -> TerminalConfig -> TextFontName,LocalConfig -> TerminalConfig -> TextFontHeight);
  164.  
  165.         BuildFontName(IBMName,LocalConfig -> TerminalConfig -> IBMFontName,LocalConfig -> TerminalConfig -> IBMFontHeight);
  166.  
  167.         if(LocalConfig != Config)
  168.         {
  169.             LocalMaxColumns    = 132;
  170.             LocalMaxLines    = 64;
  171.         }
  172.         else
  173.         {
  174.             LONG    Width,
  175.                 Height;
  176.  
  177.             if(Screen)
  178.             {
  179.                 struct Rectangle DisplayClip;
  180.  
  181.                 if(LocalConfig -> ScreenConfig)
  182.                 {
  183.                     Width    = LocalConfig -> ScreenConfig -> DisplayWidth;
  184.                     Height    = LocalConfig -> ScreenConfig -> DisplayHeight;
  185.  
  186.                     QueryOverscan(LocalConfig -> ScreenConfig -> DisplayMode,&DisplayClip,LocalConfig -> ScreenConfig -> OverscanType);
  187.                 }
  188.                 else
  189.                 {
  190.                     Width    = LocalConfig -> ScreenConfig -> DisplayWidth;
  191.                     Height    = LocalConfig -> ScreenConfig -> DisplayHeight;
  192.  
  193.                     QueryOverscan(LocalConfig -> ScreenConfig -> DisplayMode,&DisplayClip,LocalConfig -> ScreenConfig -> OverscanType);
  194.                 }
  195.  
  196.                 if(!Width)
  197.                     Width = DisplayClip . MaxX - DisplayClip . MinX + 1;
  198.  
  199.                 if(!Height)
  200.                     Height = DisplayClip . MaxY - DisplayClip . MinY + 1;
  201.             }
  202.             else
  203.             {
  204.                 Width    = Window -> WScreen -> Width - Window -> WScreen -> WBorLeft - Window -> WScreen -> WBorRight;
  205.                 Height    = Window -> WScreen -> Height - Window -> WScreen -> WBorTop - Window -> WScreen -> WBorBottom - Window -> WScreen -> Font -> ta_YSize - 1;
  206.  
  207.                 if(!StatusWindow)
  208.                     Height -= StatusDisplayHeight;
  209.  
  210.                 if(ChatMode)
  211.                     Height -= UserFontHeight + 2;
  212.             }
  213.  
  214.             if(WindowWidth > Width)
  215.                 Width = WindowWidth;
  216.  
  217.             if(WindowHeight > Height)
  218.                 Height = WindowHeight;
  219.  
  220.             LocalMaxColumns    = Width  / TextFontWidth;
  221.             LocalMaxLines    = Height / TextFontHeight;
  222.  
  223.             if(LocalMaxColumns < 20)
  224.                 LocalMaxColumns = 20;
  225.  
  226.             if(LocalMaxLines < 20)
  227.                 LocalMaxLines = 20;
  228.         }
  229.  
  230.         LT_New(Handle,
  231.             LA_Type,    VERTICAL_KIND,
  232.         TAG_DONE);
  233.         {
  234.             LT_New(Handle,
  235.                 LA_Type,VERTICAL_KIND,
  236.             TAG_DONE);
  237.             {
  238.                 LT_New(Handle,
  239.                     LA_Type,    CYCLE_KIND,
  240.                     LA_ID,        GAD_PAGER,
  241.                     LA_LabelID,    MSG_XFER_PAGE_TXT,
  242.                     GTCY_Labels,    PageTitle,
  243.                     LACY_AutoPageID,GAD_PAGEGROUP,
  244.                     LACY_TabKey,    TRUE,
  245.                     LA_BYTE,    &InitialPage,
  246.                 TAG_DONE);
  247.  
  248.                 LT_EndGroup(Handle);
  249.             }
  250.  
  251.             LT_New(Handle,
  252.                 LA_Type,    VERTICAL_KIND,
  253.                 LA_ID,        GAD_PAGEGROUP,
  254.                 LAGR_Frame,    TRUE,
  255.                 LAGR_ActivePage,InitialPage,
  256.             TAG_DONE);
  257.             {
  258.                 LT_New(Handle,
  259.                     LA_Type,    VERTICAL_KIND,
  260.                 TAG_DONE);
  261.                 {
  262.                     LT_New(Handle,
  263.                         LA_Type,    CYCLE_KIND,
  264.                         LA_LabelID,    MSG_TERMINALPANEL_EMULATION_GAD,
  265.                         LA_ID,        GAD_EMULATIONTYPE,
  266.                         LA_BYTE,    &LocalConfig -> TerminalConfig -> EmulationMode,
  267.                         LACY_FirstLabel,MSG_TERMINALPANEL_EMULATION_ANSI_VT102_TXT,
  268.                         LACY_LastLabel,    MSG_TERMINALPANEL_EMULATION_HEX_TXT,
  269.                     TAG_DONE);
  270.  
  271.                     LT_New(Handle,
  272.                         LA_Type,    STRING_KIND,
  273.                         LA_LabelID,    MSG_TERMINALPANEL_EMULATION_NAME_GAD,
  274.                         LA_Chars,    20,
  275.                         LA_ID,        GAD_EMULATIONLIBRARY,
  276.                         LA_STRPTR,    LocalConfig -> TerminalConfig -> EmulationFileName,
  277.                         GTST_MaxChars,    MAX_FILENAME_LENGTH - 1,
  278.                         LAST_Picker,    TRUE,
  279.                         GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode != EMULATION_EXTERNAL,
  280.                     TAG_DONE);
  281.  
  282.                     LT_New(Handle,
  283.                         LA_Type,    CHECKBOX_KIND,
  284.                         LA_LabelID,    MSG_EMULATIONPANEL_USE_TERMINAL_TASK_TXT,
  285.                         LA_BYTE,    &LocalConfig -> TerminalConfig -> UseTerminalTask,
  286.                         LA_ID,        GAD_EMULATIONTASK,
  287.                         GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  288.                     TAG_DONE);
  289.  
  290.                     LT_EndGroup(Handle);
  291.                 }
  292.  
  293.                 LT_New(Handle,
  294.                     LA_Type,    VERTICAL_KIND,
  295.                 TAG_DONE);
  296.                 {
  297.                     LT_New(Handle,
  298.                         LA_Type,    CYCLE_KIND,
  299.                         LA_LabelID,    MSG_TERMINALPANEL_BELL_GAD,
  300.                         LA_BYTE,    &LocalConfig -> TerminalConfig -> BellMode,
  301.                         LACY_FirstLabel,MSG_TERMINALPANEL_BELL_IGNORE_TXT,
  302.                         LACY_LastLabel,    MSG_TERMINALPANEL_BELL_DEFAULT_TXT,
  303.                     TAG_DONE);
  304.  
  305.                     if(LocalConfig -> TerminalConfig -> NumColumns < 20)
  306.                         LocalColumns = LocalMaxColumns + 1;
  307.                     else
  308.                         LocalColumns = LocalConfig -> TerminalConfig -> NumColumns;
  309.  
  310.                     LT_New(Handle,
  311.                         LA_Type,        SliderType,
  312.                         LA_LabelID,        MSG_TERMINALPANEL_NUMCOLUMNS_GAD,
  313.                         LA_ID,            GAD_COLUMNS,
  314.                         LA_LONG,        &LocalColumns,
  315.                         GTSL_Min,        20,
  316.                         GTSL_Max,        LocalMaxColumns + 1,
  317.                         GTSL_DispFunc,        ShowColumn,
  318.                         GTSL_LevelFormat,    "%s",
  319.                     TAG_DONE);
  320.  
  321.                     if(LocalConfig -> TerminalConfig -> NumLines < 20)
  322.                         LocalLines = LocalMaxLines + 1;
  323.                     else
  324.                         LocalLines = LocalConfig -> TerminalConfig -> NumLines;
  325.  
  326.                     LT_New(Handle,
  327.                         LA_Type,        SliderType,
  328.                         LA_LabelID,        MSG_TERMINALPANEL_NUMLINES_GAD,
  329.                         LA_LONG,        &LocalLines,
  330.                         LA_ID,            GAD_LINES,
  331.                         GTSL_Min,        20,
  332.                         GTSL_Max,        LocalMaxLines + 1,
  333.                         GTSL_DispFunc,        ShowLine,
  334.                         GTSL_LevelFormat,    "%s",
  335.                     TAG_DONE);
  336.  
  337.                     LT_New(Handle,
  338.                         LA_Type,    STRING_KIND,
  339.                         LA_LabelID,    MSG_TERMINALPANEL_KEYMAP_FILE_GAD,
  340.                         LA_Chars,    20,
  341.                         LA_ID,        GAD_KEYMAP,
  342.                         LA_STRPTR,    LocalConfig -> TerminalConfig -> KeyMapFileName,
  343.                         GTST_MaxChars,    MAX_FILENAME_LENGTH - 1,
  344.                         LAST_Picker,    TRUE,
  345.                     TAG_DONE);
  346.  
  347.                     LT_EndGroup(Handle);
  348.                 }
  349.  
  350.                 LT_New(Handle,
  351.                     LA_Type,    VERTICAL_KIND,
  352.                 TAG_DONE);
  353.                 {
  354.                     LT_New(Handle,
  355.                         LA_Type,    TEXT_KIND,
  356.                         LA_LabelID,    MSG_TERMINALPANEL_TEXT_FONT_GAD,
  357.                         LA_Chars,    20,
  358.                         LA_ID,        GAD_TEXTFONT,
  359.                         GTTX_Text,    FontName,
  360.                         GTTX_Border,    TRUE,
  361.                         LATX_Picker,    TRUE,
  362.                         LATX_LockSize,    TRUE,
  363.                         GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  364.                     TAG_DONE);
  365.  
  366.                     LT_New(Handle,
  367.                         LA_Type,    TEXT_KIND,
  368.                         LA_LabelID,    MSG_TERMINALPANEL_IBM_FONT_GAD,
  369.                         LA_Chars,    20,
  370.                         LA_ID,        GAD_IBMFONT,
  371.                         GTTX_Text,    IBMName,
  372.                         GTTX_Border,    TRUE,
  373.                         LATX_Picker,    TRUE,
  374.                         LATX_LockSize,    TRUE,
  375.                         GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  376.                     TAG_DONE);
  377.  
  378.                     LT_New(Handle,
  379.                         LA_Type,    CYCLE_KIND,
  380.                         LA_LabelID,    MSG_TERMINALPANEL_FONT_GAD,
  381.                         LA_ID,        GAD_FONTMODE,
  382.                         LA_BYTE,    &LocalConfig -> TerminalConfig -> FontMode,
  383.                         LACY_FirstLabel,MSG_TERMINALPANEL_FONT_STANDARD_TXT,
  384.                         LACY_LastLabel,    MSG_TERMINALPANEL_FONT_PC_RAW,
  385.                         GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  386.                     TAG_DONE);
  387.  
  388.                     LT_EndGroup(Handle);
  389.                 }
  390.  
  391.                 LT_New(Handle,
  392.                     LA_Type,    HORIZONTAL_KIND,
  393.                 TAG_DONE);
  394.                 {
  395.                     LT_New(Handle,
  396.                         LA_Type,    VERTICAL_KIND,
  397.                     TAG_DONE);
  398.                     {
  399.                         LT_New(Handle,
  400.                             LA_Type,    CYCLE_KIND,
  401.                             LA_LabelID,    MSG_TERMINALPANEL_SEND_CR_GAD,
  402.                             LA_BYTE,    &LocalConfig -> TerminalConfig -> SendCR,
  403.                             GTCY_Labels,    EOL_Labels,
  404.                         TAG_DONE);
  405.  
  406.                         LT_New(Handle,
  407.                             LA_Type,    CYCLE_KIND,
  408.                             LA_LabelID,    MSG_TERMINALPANEL_SEND_LF_GAD,
  409.                             LA_BYTE,    &LocalConfig -> TerminalConfig -> SendLF,
  410.                             GTCY_Labels,    EOL_Labels,
  411.                         TAG_DONE);
  412.  
  413.                         LT_EndGroup(Handle);
  414.                     }
  415.  
  416.                     LT_New(Handle,
  417.                         LA_Type,    VERTICAL_KIND,
  418.                     TAG_DONE);
  419.                     {
  420.                         LT_New(Handle,
  421.                             LA_Type,    YBAR_KIND,
  422.                         TAG_DONE);
  423.  
  424.                         LT_EndGroup(Handle);
  425.                     }
  426.  
  427.                     LT_New(Handle,
  428.                         LA_Type,    VERTICAL_KIND,
  429.                     TAG_DONE);
  430.                     {
  431.                         LT_New(Handle,
  432.                             LA_Type,    CYCLE_KIND,
  433.                             LA_LabelID,    MSG_TERMINALPANEL_RECEIVE_CR_GAD,
  434.                             LA_BYTE,    &LocalConfig -> TerminalConfig -> ReceiveCR,
  435.                             GTCY_Labels,    EOL_Labels,
  436.                         TAG_DONE);
  437.  
  438.                         LT_New(Handle,
  439.                             LA_Type,    CYCLE_KIND,
  440.                             LA_LabelID,    MSG_TERMINALPANEL_RECEIVE_LF_GAD,
  441.                             LA_BYTE,    &LocalConfig -> TerminalConfig -> ReceiveLF,
  442.                             GTCY_Labels,    EOL_Labels,
  443.                         TAG_DONE);
  444.  
  445.                         LT_EndGroup(Handle);
  446.                     }
  447.  
  448.                     LT_EndGroup(Handle);
  449.                 }
  450.  
  451.                 LT_EndGroup(Handle);
  452.             }
  453.  
  454.             LT_New(Handle,
  455.                 LA_Type,    VERTICAL_KIND,
  456.             TAG_DONE);
  457.             {
  458.                 LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
  459.  
  460.                 LT_EndGroup(Handle);
  461.             }
  462.  
  463.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  464.                 LAGR_SameSize,    TRUE,
  465.                 LAGR_Spread,    TRUE,
  466.             TAG_DONE);
  467.             {
  468.                 LT_New(Handle,
  469.                     LA_Type,    BUTTON_KIND,
  470.                     LA_LabelID,    MSG_GLOBAL_USE_GAD,
  471.                     LA_ID,        GAD_USE,
  472.                     LABT_ReturnKey,    TRUE,
  473.                     LABT_ExtraFat,    TRUE,
  474.                 TAG_DONE);
  475.  
  476.                 if(Default)
  477.                 {
  478.                     LT_New(Handle,
  479.                         LA_Type,    BUTTON_KIND,
  480.                         LA_LabelID,    MSG_GLOBAL_DEFAULT_GAD,
  481.                         LA_ID,        GAD_DEFAULT,
  482.                         LABT_ExtraFat,    TRUE,
  483.                     TAG_DONE);
  484.                 }
  485.  
  486.                 LT_New(Handle,
  487.                     LA_Type,    BUTTON_KIND,
  488.                     LA_LabelID,    MSG_GLOBAL_CANCEL_GAD,
  489.                     LA_ID,        GAD_CANCEL,
  490.                     LABT_EscKey,    TRUE,
  491.                     LABT_ExtraFat,    TRUE,
  492.                 TAG_DONE);
  493.  
  494.                 LT_EndGroup(Handle);
  495.             }
  496.  
  497.             LT_EndGroup(Handle);
  498.         }
  499.  
  500.         if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_TERMINALPANEL_TERMINAL_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
  501.             LAWN_HelpHook,        &GuideHook,
  502.             LAWN_Parent,        Window,
  503.             WA_DepthGadget,        TRUE,
  504.             WA_CloseGadget,        TRUE,
  505.             WA_DragBar,        TRUE,
  506.             WA_RMBTrap,        TRUE,
  507.             WA_Activate,        TRUE,
  508.         TAG_DONE))
  509.         {
  510.             struct IntuiMessage    *Message;
  511.             BOOLEAN             Done = FALSE;
  512.             ULONG             MsgClass,
  513.                          MsgQualifier;
  514.             UWORD             MsgCode;
  515.             struct Gadget        *MsgGadget;
  516.             UBYTE             DummyBuffer[MAX_FILENAME_LENGTH];
  517.  
  518.             GuideContext(CONTEXT_TERMINAL);
  519.  
  520.             PushWindow(PanelWindow);
  521.  
  522.             LT_ShowWindow(Handle,TRUE);
  523.  
  524.             do
  525.             {
  526.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  527.                 {
  528.                     SaveConfig(PrivateConfig,LocalConfig);
  529.  
  530.                     break;
  531.                 }
  532.  
  533.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
  534.                 {
  535.                     MsgClass    = Message -> Class;
  536.                     MsgQualifier    = Message -> Qualifier;
  537.                     MsgCode        = Message -> Code;
  538.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  539.  
  540.                     GT_ReplyIMsg(Message);
  541.  
  542.                     LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  543.  
  544.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  545.                     {
  546.                         SaveConfig(PrivateConfig,LocalConfig);
  547.  
  548.                         Done = TRUE;
  549.                     }
  550.  
  551.                     if(MsgClass == IDCMP_GADGETUP)
  552.                     {
  553.                         switch(MsgGadget -> GadgetID)
  554.                         {
  555.                             case GAD_USE:
  556.  
  557.                                 LT_UpdateStrings(Handle);
  558.  
  559.                                 LocalConfig -> TerminalConfig -> NumColumns    = LocalColumns % (LocalMaxColumns + 1);
  560.                                 LocalConfig -> TerminalConfig -> NumLines    = LocalLines % (LocalMaxLines + 1);
  561.  
  562.                                 if(!LocalConfig -> TerminalConfig -> EmulationFileName[0] && LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL)
  563.                                     LocalConfig -> TerminalConfig -> EmulationMode = EMULATION_ANSIVT100;
  564.  
  565.                                 Done = TRUE;
  566.                                 break;
  567.  
  568.                             case GAD_EMULATIONTYPE:
  569.  
  570.                                 LT_SetAttributes(Handle,GAD_TEXTFONT,
  571.                                     GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  572.                                 TAG_DONE);
  573.  
  574.                                 LT_SetAttributes(Handle,GAD_IBMFONT,
  575.                                     GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  576.                                 TAG_DONE);
  577.  
  578.                                 LT_SetAttributes(Handle,GAD_FONTMODE,
  579.                                     GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  580.                                 TAG_DONE);
  581.  
  582.                                 LT_SetAttributes(Handle,GAD_EMULATIONLIBRARY,
  583.                                     GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode != EMULATION_EXTERNAL,
  584.                                 TAG_DONE);
  585.  
  586.                                 LT_SetAttributes(Handle,GAD_EMULATIONTASK,
  587.                                     GA_Disabled,    LocalConfig -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  588.                                 TAG_DONE);
  589.  
  590.                                 break;
  591.  
  592.                             case GAD_CANCEL:
  593.  
  594.                                 SaveConfig(PrivateConfig,LocalConfig);
  595.  
  596.                                 Cancel = Done = TRUE;
  597.                                 break;
  598.  
  599.                             case GAD_DEFAULT:
  600.  
  601.                                 *Default = TRUE;
  602.  
  603.                                 Done = TRUE;
  604.                                 break;
  605.                         }
  606.                     }
  607.  
  608.                     if(MsgClass == IDCMP_IDCMPUPDATE)
  609.                     {
  610.                         switch(MsgGadget -> GadgetID)
  611.                         {
  612.                             case GAD_EMULATIONLIBRARY:
  613.  
  614.                                 LT_LockWindow(PanelWindow);
  615.  
  616.                                 strcpy(DummyBuffer,(STRPTR)LT_GetAttributes(Handle,GAD_EMULATIONLIBRARY,TAG_DONE));
  617.                                 strcpy(SharedBuffer,DummyBuffer);
  618.  
  619.                                 if(PickFile(PanelWindow,"Libs:","xem#?.library",LocaleString(MSG_TERMINALPANEL_SELECT_EMULATOR_TXT),SharedBuffer,NT_LIBRARY))
  620.                                 {
  621.                                     if(Stricmp(SharedBuffer,DummyBuffer))
  622.                                         LT_SetAttributes(Handle,GAD_EMULATIONLIBRARY,GTST_String,SharedBuffer,TAG_DONE);
  623.                                 }
  624.  
  625.                                 LT_ShowWindow(Handle,TRUE);
  626.  
  627.                                 LT_UnlockWindow(PanelWindow);
  628.                                 break;
  629.  
  630.                             case GAD_KEYMAP:
  631.  
  632.                                 LT_LockWindow(PanelWindow);
  633.  
  634.                                 strcpy(DummyBuffer,(STRPTR)LT_GetAttributes(Handle,GAD_KEYMAP,TAG_DONE));
  635.  
  636.                                 if(SelectKeymap(DummyBuffer,PanelWindow))
  637.                                     LT_SetAttributes(Handle,GAD_KEYMAP,GTST_String,SharedBuffer,TAG_DONE);
  638.  
  639.                                 LT_UnlockWindow(PanelWindow);
  640.                                 break;
  641.  
  642.                             case GAD_TEXTFONT:
  643.  
  644.                                 LT_LockWindow(PanelWindow);
  645.  
  646.                                 if(PickFont(PanelWindow,LocalConfig -> TerminalConfig -> TextFontName,&LocalConfig -> TerminalConfig -> TextFontHeight,TRUE))
  647.                                 {
  648.                                     BuildFontName(FontName,LocalConfig -> TerminalConfig -> TextFontName,LocalConfig -> TerminalConfig -> TextFontHeight);
  649.  
  650.                                     LT_SetAttributes(Handle,GAD_TEXTFONT,
  651.                                         GTTX_Text,    FontName,
  652.                                     TAG_DONE);
  653.                                 }
  654.  
  655.                                 LT_UnlockWindow(PanelWindow);
  656.                                 break;
  657.  
  658.                             case GAD_IBMFONT:
  659.  
  660.                                 LT_LockWindow(PanelWindow);
  661.  
  662.                                 if(PickFont(PanelWindow,LocalConfig -> TerminalConfig -> IBMFontName,&LocalConfig -> TerminalConfig -> IBMFontHeight,TRUE))
  663.                                 {
  664.                                     BuildFontName(IBMName,LocalConfig -> TerminalConfig -> IBMFontName,LocalConfig -> TerminalConfig -> IBMFontHeight);
  665.  
  666.                                     LT_SetAttributes(Handle,GAD_IBMFONT,
  667.                                         GTTX_Text,    IBMName,
  668.                                     TAG_DONE);
  669.                                 }
  670.  
  671.                                 LT_UnlockWindow(PanelWindow);
  672.                                 break;
  673.                         }
  674.                     }
  675.                 }
  676.             }
  677.             while(!Done);
  678.  
  679.             PopWindow();
  680.         }
  681.  
  682.         LT_DeleteHandle(Handle);
  683.     }
  684.  
  685.     if(Default)
  686.         return((BYTE)(!Cancel));
  687.     else
  688.         return((BYTE)memcmp(PrivateConfig -> TerminalConfig,LocalConfig -> TerminalConfig,sizeof(struct TerminalSettings)));
  689. }
  690.